/*******************************************************************************
 * Copyright (c) 2008 meihuichina.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.langqiao.oop.clone.deep;

import java.io.IOException;

/**
 * 串行化却很耗时，在一些框架中，我们便可以感受到，它们往往将对象进行串行化后进行传递，耗时较多
 */

public class DeepCopy2 {
	
	public static void main(String[] args) throws IOException, ClassNotFoundException {
		long t1 = System.currentTimeMillis();
		Professor2 p = new Professor2("wangwu", 50);
		Student2 s1 = new Student2("zhangsan", 18, p);
		Student2 s2 = (Student2) s1.deepCopy();
		s2.p.name = "lisi";
		s2.p.age = 30;
		System.out.println("name=" + s1.p.name + "," + "age=" + s1.p.age); // 学生1的教授不改变。
		long t2 = System.currentTimeMillis();
		System.out.println(t2-t1);
	}
}
